var rightPressed = false;
var leftPressed = false;

document.addEventListener("keydown", function(event) {
	// console.log('event.key keydown=', event.key);
	if (event.key == "ArrowRight") {
		rightPressed = true;
	} else if (event.key == "ArrowLeft") {
		leftPressed = true;
	}
});

document.addEventListener("keyup", function(event) {
	// console.log('event.key= keydown', event.key);
	if (event.key == "ArrowRight") {
		rightPressed = false;
	} else if (event.key == "ArrowLeft") {
		leftPressed = false;
	}
});